package net.ib.mtalk.ui.dialog;

import java.util.ArrayList;
import java.util.List;

import com.google.protobuf.micro.InvalidProtocolBufferMicroException;

import net.ib.mntalk.protocol.Common.BuddyInfo;
import net.ib.mtalk.database.DatabaseContract.BuddyTable;
import net.ib.mtalk.database.DatabaseContract.ContactTable;
import net.ib.mtalk.ui.buddy.contact.BuddyContactListActivity;
import net.ib.mtalk.ui.inbox.InboxListActivity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.DialogInterface.OnClickListener;
import android.database.Cursor;
import android.net.Uri;
import android.view.View;

public class DialogMenu3 implements OnClickListener{

	AlertDialog mDialog;
	private long mContactsId;
	private DialogAdapter mAdapter;
	private Context mContext;
	private ArrayList<DialogListItem> mItem;
	private View mView;
	
	public DialogMenu3(Context context, ArrayList<DialogListItem> item){
		mContext = context;
		mItem = item;
//		mContactsId = contacts_id;
//		mView = v;
	}
	
	public Dialog createDialog(){
		AlertDialog.Builder builder = null;
		
		if(mItem != null){
			mAdapter = new DialogAdapter(mContext, mItem);
		}
		builder = new AlertDialog.Builder(mContext);
		builder.setAdapter(mAdapter, this);
		builder.setInverseBackgroundForced(true);
		mDialog = builder.create();
		
		return mDialog;
	}
	
	@Override
	public void onClick(DialogInterface dialog, int which) {
		DialogListItem item = (DialogListItem) mAdapter.getItem(which);
		Intent intent = new Intent(Intent.ACTION_CALL);
		intent.setData(Uri.parse("tel:" + item.text));
		mContext.startActivity(intent);
	}

}
